<?php
/**
 * Project: AIGC
 * Author: moufer <moufer@163.com>
 * Date: 2024/7/19 22:28
 */

namespace module\chat\controller\admin;

use app\library\Controller;
use mof\annotation\AdminPerm;
use mof\annotation\Description;
use mof\annotation\InjectLogic;
use mof\ApiResponse;
use mof\Logic;
use think\response\Json;

#[AdminPerm(
    title: '对话记录', url: 'chat/message', actions: '*',
    sort: 5, icon: 'ChatLineRound', group: 'main'
)]
class Message extends Controller
{
    #[InjectLogic(\module\chat\model\Message::class)]
    protected Logic $logic;

    public function index(): Json
    {
        return ApiResponse::success(
            $this->logic->paginate(
                $this->request->searcher()
                    ->params(['received' => 1], false)
                    ->with(['user', 'object', 'channel'])
            )
        );
    }

    public function delete($id): Json
    {
        $this->logic->delete($id);
        return ApiResponse::success();
    }

    public function deletes(): Json
    {
        $this->logic->deletes($this->request->getPostIds());
        return ApiResponse::success();
    }
}